#include <iostream>
#include <string.h>
#define MAXN 201 
using namespace std;


int n,m,k;   //左边n个点,右边m个点

int map[MAXN][MAXN]; //存二部图的二维数组,有边则为1
int ans;			//存最大匹配方案数(也就是最小覆盖的点数)
int cx[MAXN],cy[MAXN],sx[MAXN],sy[MAXN];
//cx,cy:左右两边是否分配过.
//sx,sy:左右两边是否调整过.
int path(int u)
{
	int v;

	sx[u]=1;
	for (v=1;v<=m;v++)
		if (map[u][v]==1 && !sy[v]) 
		{
			sy[v]=1;
			if ( !cy[v] || path(cy[v]))
			{
				cx[u]=v;
				cy[v]=u;
				return 1;
			}
		}
	return 0;
}


void solve()
{
	int i;
	memset(cx,0,sizeof(cx));
	memset(cy,0,sizeof(cy));
	ans=0;
	for (i=1;i<=n;i++)
		if (!cx[i]) 
		{
			memset(sx,0,sizeof(sx));
			memset(sy,0,sizeof(sy));
			ans+=path(i);     
		}


}

char pp[21][4];
int range[6][2];
int tshirt[6];

int sizetoint(char ch)
{
    if (ch=='S') return 1;
    if (ch=='M') return 2;
    if (ch=='L') return 3;
    if (ch=='X') return 4;
    if (ch=='T') return 5;
}    

int main()
{
    char ss[20];
    int i,j, begin, end, a, b;
    while (scanf("%s", ss))
    {
            
        if (ss[0]=='E') break;
        memset(map, 0, sizeof(map));
        memset(pp, 0, sizeof(pp));
        
        scanf("%d", &n);
        for (i=1; i<=n; ++i) scanf("%s", pp[i]);
        for (i=1; i<=5; ++i) scanf("%d", tshirt+i);
        
        begin = 0;
        for (i=1; i<=5; ++i)
       	{
       	    if (tshirt[i] == 0) 
       	    {
       	        range[i][0]=range[i][1]=0;
       	    }    
       	    else
       	    {
       	        end = begin + tshirt[i];
       	        begin ++;
       	        range[i][0] = begin;
       	        range[i][1] = end;
       	    }    
       	}    
       	m = end;
       	for (i=1; i<=n; ++i)
       	{
       	    a = sizetoint(pp[i][0]);
       	    b = sizetoint(pp[i][1]);
       	    for (k=a; k<=b; ++k)
       	    {
       	        if (range[k][0] == 0) continue;
       	        for (j=range[k][0]; j<=range[k][1]; ++j)
       	        	map[i][j] = 1;
       	    }    
       	}    
       	solve();
        if (ans == n) printf("T-shirts rock!\n");
        else printf("I'd rather not wear a shirt anyway...\n");

        scanf("%s", ss);
        
        
    }    

    
    
    return 0;
}    











